#include <iostream>
using namespace std;
const int N = 2e5+10;
int a[N];
int n;
int ans=0;
int main() {
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0,j=1;i<n;i++)
    {
        j=i+1;
        while(j<n&&(a[j]-a[j-1]<=8))
        {
            ++j;
        }
        ans=max(ans,j-i);
        i=j-1;
    }
    cout << ans;
    return 0;
}